
package com.zerone.pay.test;

import org.apache.commons.lang3.StringUtils;

import com.acooly.coder.Generator;
import com.acooly.coder.generate.impl.DefaultCodeGenerateService;

/**
 * 代码生成工具
 */
public class AcoolyCoder {
	public static void main(String[] args) {
		DefaultCodeGenerateService service = (DefaultCodeGenerateService) Generator.getGenerator();
		//set workspace if possible
		if (StringUtils.isBlank(service.getGenerateConfiguration().getWorkspace())) {
			String workspace=getProjectPath() + "pay-core";
			service.getGenerateConfiguration().setWorkspace(workspace);
		}
		//set root pacakge if possible
		if (StringUtils.isBlank(service.getGenerateConfiguration().getRootPackage())) {
			service.getGenerateConfiguration().setRootPackage(getRootPackage());
		}
		service.generateTable("trade","trade_info");
	}

    public static String getProjectPath() {
        String file = AcoolyCoder.class.getClassLoader().getResource(".").getFile();
        String testModulePath = file.substring(0, file.indexOf( "/target/"));
        String projectPath = testModulePath.substring(0, testModulePath.lastIndexOf("/"));
        return projectPath+"/";
    }
    private static String getRootPackage() {
		return "com.zerone.pay.merchant";
	}
}
